<template>
	<view class="">
		<view class="left" @tap.stop="back">
			<image src="@/static/home/left.png" mode=""></image>
		</view>
		<view class="textName">
			保护装置详情
		</view>
		<view class="">
			<view class="order">
				<!-- 列表 -->
				<view class="listBox">
			<!-- 		<scroll-view enable-back-to-top=true scroll-y="true" class="scrollHight"  :style="{height:height}"  @scrolltoupper="upper"
						@scrolltolower="lower" :refresher-enabled="true" :refresher-threshold="100"
						:refresher-triggered="isTriggered" @refresherrefresh="onRefresh" @refresherrestore="onRestore"
						@refresherpulling="onPulling"> v-for="(item,index) in tabList" :key="index" -->
						<view class="list" >
							<view class="" >
								<view class="code" style="font-size: 30rpx;display: flex;">
									<view class="title">设备保护型号：</view>
									<view class="content">{{allList.protectDeviceModel||''}}</view>
								</view>
								<view class="line"></view>
								<view class="code" style="font-size: 30rpx;display: flex;">
									<view class="title" >
										设备保护类型：
									</view>
									<view class="content">
										{{allList.protectDeviceType||''}}
									</view>
								</view>
								<view class="line"></view>
								<view class="code" style="font-size: 30rpx;display: flex;">
									<view class="title" >
										厂家名称：
									</view>
									<view class="content">
										{{allList.manufacturer||''}}
									</view>
								</view>
								<view class="line"></view>
								<view class="code" style="font-size: 30rpx;">
									<view class="" >
										原理图：
									</view>
									<view class="" style="display: flex;">
										<view class="" v-for="(i,a) in allList.principleImgUrl" :key="a" style="width: 200rpx;height: 200rpx;margin: 20rpx;">
											<image :src="image + i" mode="" style="width: 200rpx;height: 200rpx;"></image>
										</view>
									</view>
									
								</view>
							</view>
						</view>
						<!-- 提示栏 -->
						<!-- <view style="width: 100%; text-align: center; font-size: 28rpx; margin-top: 30rpx;">{{isText}}</view> -->
					<!-- </scroll-view> -->
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	import vvSelect from '@/pages/components/vv-select/vv-select.vue'
	export default {
		data() {
			return {
				image: this.$base.smallimgUrl,
				tabCurrent: 0,
				page: 1,
				isText: '',
				allList:{},
				typeId:'',
				last_page:1,
				height: this.$utils.height(),
				isTriggered: false, //定义一个用来表示下拉刷新是否被触发，当更新完数据需要重新定义为false
				protectDeviceId:''
			};
		},
		components: {
			vvSelect,
		},
		onLoad(options) {
			this.protectDeviceId = options.protectDeviceId
			console.log(this.protectDeviceId,'我进来拉')
			this.getProtectDeviceId()
		},
		onReady() {
			this.height = uni.getSystemInfoSync().windowHeight - 82 + 'px';
		},
		onShow(){
			this.list = []
			this.page = 1
			this.isText = ''
			// this.getOrderList()
		},
		methods: {
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			getProtectDeviceId(){
				let that = this
				that.$api.protectDeviceId(that.protectDeviceId).then(res => {
					that.allList = res.data.data
					that.allList.principleImgUrl = (that.allList.principleImgUrl||'').split(',')
					console.log(that.allList,'protectDeviceId')
				})
			},
			submi(){
				uni.navigateTo({
					url:'/pages/tabBar/parameterDetails/parameterDetails'
				})
			},
			lower: function(e) {
				// if (this.form.page < this.last_page) {
				// 	this.form.page = this.form.page + 1
					
				// 	// this.projectList()
				// }
			},
			upper: function(e) {
				// console.log('到达顶部吧')
			},
			onPulling(e) {
				if (e.detail.deltaY < 0) return // 防止上滑页面也触发下拉
				this.isTriggered = true;
				// console.log("onpulling", e);
			},
			onRefresh() {
				// console.log("自定义下拉刷新被触发");
				this.closeSel()
				this.isTriggered = false;
			},
			// 选择系列
			tabChange(e){
				this.typeId = e
				this.list = []
				this.page = 1
				this.isText = ''
				this.getOrderList()
			},
			// 获取列表
			getOrderList(){
				let that = this
				that.$api.detailsList({
					page: that.page,
					typeId: that.typeId,
					state:1
				}).then(res => {
					res.data.rows.length == 0 ? that.isText = '暂无数据' : that.isText = ''
					// that.list = that.list.concat(res.data.rows)
					// that.list = 
					that.last_page = Math.ceil(res.data.rows.length / res.data.total)
					console.log(this.last_page,'this.last_page')
				})
			},
			// 点击提货
			pickUpGoods(el){
				let that = this
				uni.showModal({
				 title:  "确定是否提货",
				 success: function (res) {
					  if (res.confirm) {
							that.$api.orderTh({
							 	order_number: el.order_number,
							}).then(res => {
							 	console.log(res)
								that.goDetails(el)
							})
					    } else{
							 console.log('用户点击取消');
					    }
					}
				});
				
			},
			// 点击回购
			buyBack(el){
				let that = this
				uni.showModal({
					 title:  "确定是否回购",
					 success: function (res) {
						if (res.confirm) {
							 console.log('用户点击确定');
							 that.$api.orderHg({
								order_number: el.order_number,
							 }).then(res => {
								console.log(res)
								that.goDetails(el)
							 }) 
						} else{
							 console.log('用户点击取消');
						}
					}
				});
			},
			
			// 跳转到详情页面
			goDetails(el){
				let res = {
					order_number: el.order_number,
					goods_img: el.goods_img,
					goods_name: el.goods_name
				}
				uni.navigateTo({
					url: '/pages/order/details/details?res=' + JSON.stringify(res)
				})
			}
		},
		onReachBottom() {
			let that = this
			if (that.page < that.last_page) {
				that.page = that.page + 1
				that.getOrderList()
			}
		}
		
	}
</script>

<style lang="less">
	page{
		background-color: #fff;
	}
	.left {
		top: 3.8%;
		left: 4%;
		position: fixed;
	
		image {
			width: 21rpx;
			height: 35rpx;
		}
	}
	.textName{
		top: 3%;
		left: 38%;
		position: fixed;
		color: #000;
		font-size: 34rpx;
	}
	.butt{
		position: absolute;
		bottom: 40rpx;
		left: 5%;
		width: 90%;
		height: 80rpx;
		text-align: center;
		margin: 0 auto;
		background: #469D96;
		color: #fff;
		border-radius: 10rpx;
		line-height: 80rpx;
		
	}
	.u-tab-bar{
		display: none !important;
	}
	.list{
		width: 100%;
		height: auto;
		padding: 20rpx;
		border-radius: 20rpx;
		background-color: #fff;
		margin: 20rpx auto;
			
		.rece{
			width: 22%;
			height: 60rpx;
			background: #979797;
			color: #fff;
			text-align: center;
			line-height: 60rpx;
			border-radius: 6rpx;
			margin-top: 80rpx;
		}

		.list_b{
			font-size: 28rpx;
			font-weight: 400;
			color: #7F8084;
			padding-top: 30rpx;
			.text{
				.money{
					display: inline-block;
					font-size: 32rpx;
					font-weight: 600;
					color: #000;
				}
			}
		}
		
		.btnBox{
			width: 100%;
			margin-top: 30rpx;
			flex-direction: row-reverse !important;
			.btn{
				width: 132rpx;
				height: 46rpx;
				line-height: 46rpx;
				border-radius: 46rpx;
				text-align: center;
				background-color: #000;
				color: #fff;
				font-size: 24rpx;
				font-weight: 500;
			}
		}
		
	}
	.serchView {
		width: 100%;
		height: 120rpx;
		display: flex;
		flex-direction: column;
		background-color: #FFFFFF;
		align-items: center;
		justify-content: center;
	}
	.serch {
		width: 690rpx;
		height: 80rpx;
		background: #F7F7F7;
		border-radius: 20rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	 
	.serchIconImage {
		width: 32rpx;
		height: 32rpx;
		margin-left: 30rpx;
	}
	 
	.serchInput {
		height: 70rpx;
		width: 600rpx;
		margin-left: 12rpx;
		font-size: 30rpx;
		color: #000000;
	}
	.chooseCup {
		margin-right: 8rpx !important;
	
		image {
			width: 20rpx !important;
			height: 12rpx !important;
			margin: 14rpx;
		}
	}
	.order{
		width: 100vw;
		.tabBox{
			width: 100%;
			// height: 100rpx;
		}
		.listBox{
			width: 100%;
			margin: 120rpx 0 30rpx;
			// padding: 0 30rpx;
			// background: rebeccapurple;
			// height: 600rpx;
			.list{
				width: 100%;
				height: auto;
				padding: 20rpx 30rpx;
				border-radius: 20rpx;
				background-color: #fff;
				margin: 20rpx auto;
				.code{
					color: #000;
					font-weight: 400;
					font-size: 12px;
					line-height:80rpx;
					height: 80rpx;
					// margin-bottom: 10rpx;
					.title{
						width: 36%;
					}
					.content{
						width: 63%;
						color: #979797;
						white-space: nowrap; 
						overflow: hidden;
						text-overflow: ellipsis;

					}
				}
				.line{
					width: 100%;
					height: 2rpx;
					background: #f0f0f0;
					margin: 0 auto;
				}
				.list_b{
					font-size: 28rpx;
					font-weight: 400;
					color: #7F8084;
					padding-top: 30rpx;
					.text{
						.money{
							display: inline-block;
							font-size: 32rpx;
							font-weight: 600;
							color: #000;
						}
					}
				}
				
				.btnBox{
					width: 100%;
					margin-top: 30rpx;
					flex-direction: row-reverse !important;
					.btn{
						width: 132rpx;
						height: 46rpx;
						line-height: 46rpx;
						border-radius: 46rpx;
						text-align: center;
						background-color: #000;
						color: #fff;
						font-size: 24rpx;
						font-weight: 500;
					}
				}
				
			}
		}
	}
</style>
